#ifndef WIDGET5_H
#define WIDGET5_H

#include <QWidget>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QVector>


class Widget5 : public QWidget
{
    Q_OBJECT
public:
    explicit Widget5(QWidget *parent = nullptr);
     ~Widget5()override;
    void init();
    //绘制事件
    void paintEvent(QPaintEvent *)override;
    //图形绘制
    void paintSomething();
    //练习
    void doExercise();
signals:

public slots:
private:
    QPen * pen;
    QBrush * brush;
    QLine  * line;
    //生成4条线段
    QVector<QLine> genarate(QLine &line);
    //（向y轴方向旋转）旋转 centerPoint:中心点 rotatePoint：要旋转的点 angle:旋转的角度
    QPoint yRotate(const QPoint &centerPoint, const QPoint &rotatePoint, int angle);
    //（向x轴方向旋转）旋转 centerPoint:中心点 rotatePoint：要旋转的点 angle:旋转的角度
    QPoint xRotate(const QPoint &centerPoint, const QPoint &rotatePoint, int angle);
    //绘制koch线 line:给定的直线， deep:递归深度
    void drawKochLines(QLine & line, int deep, QPainter & painter);
};

#endif // WIDGET5_H
